# Coordinates user registration, login and logout
class SessionsController < ApplicationController
	
	skip_before_filter :store_location
	skip_before_filter :require_logged_in
	skip_before_filter :enforce_access_control
	
	# Registration page
	def new
	end

	# User login
	def create
		user = User.find_by_email(params[:email])
		if user && user.authenticate(params[:password])
			log_in user, params[:remember_me]
			redirect_back_or home_path, notice: t('session.create.successful')
		else
			flash.now[:error] = t 'session.invalid_authentication_credentials'
			render 'new'
		end
	end

	# User logout
	def destroy
		log_out
	end
	
end
